package biz.ezcom.design.pattern.memento;

/**
 * 游戏中，角色的状态 
 */
public class State implements Cloneable{
	private int attack;//攻击力
	private int defense;//防御力
	private int vitality;//生命力
	
	public int getAttack() {
		return attack;
	}
	public void setAttack(int attack) {
		this.attack = attack;
	}
	public int getDefense() {
		return defense;
	}
	public void setDefense(int defense) {
		this.defense = defense;
	}
	public int getVitality() {
		return vitality;
	}
	public void setVitality(int vitality) {
		this.vitality = vitality;
	}
	@Override
	public Object clone() {
		Object object;
		try {
			object = super.clone();
		} catch (CloneNotSupportedException e) {
			State state = new State();
			state.setAttack(this.getAttack());
			state.setDefense(this.getDefense());
			state.setVitality(this.getVitality());
			object = state;
		}
		return object;
	}
	
	@Override
	public String toString() {
		return "攻击力：" + getAttack() + "\n" 
			+ "防御力：" + getDefense() + "\n"
			+ "生命值：" + getVitality() + "\n";
	}
}
